home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / 3dvect37.zip / KB.ASM < prev    next >
Assembly Source File  |  1994-06-22  |  4KB  |  133 lines

  1.         .386p
  2.         jumps
  3. code32  segment para public use32
  4.         assume cs:code32, ds:code32
  5.  
  6. include pmode.ext
  7.  
  8. public  _kbtbl0, _kbtbl1, _kbchar, _kbshift, _kbhit
  9.  
  10. public  _initkb, _resetkb, _getch, _clearkb
  11.  
  12. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  13. ; DATA
  14. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  15. opmirq1         dd      ?               ; old IRQ1 vektor
  16. ormirq1         dd      ?               ; old real mode IRQ1 vektor
  17.  
  18. _kbtbl0         db      80h dup(0)      ; non-sticky keyboard table
  19. _kbtbl1         db      80h dup(0)      ; sticky keyboard table
  20. _kbchar         db      ?               ; last key that was hit
  21. _kbshift        db      ?               ; shift states for lask key
  22. _kbhit          db      0               ; 0=no key hit, 1=key hit available
  23.  
  24. kbrmirqbuf      db      21 dup(?)
  25.  
  26. kbxtbl          db      0,14,'1234567890-=',16,15,'qwertyuiop[]',13,0
  27.                 db      'asdfghjkl;''`',0,'\zxcvbnm,./',0,'*',0,32,0
  28.                 db      1,2,3,4,5,6,7,8,9,10,0,0,19,25,21,'-',23,'5'
  29.                 db      24,'+',20,26,22,17,18,0,0,0,11,12,27h dup(0)
  30.                 db      0,14,'!@#$%^&*()_+',16,15,'QWERTYUIOP{}',13,0
  31.                 db      'ASDFGHJKL:"~',0,'|ZXCVBNM<>?',0,'*',0,32,0
  32.                 db      1,2,3,4,5,6,7,8,9,10,0,0,19,25,21,'-',23,'5'
  33.                 db      24,'+',20,26,22,17,18,0,0,0,11,12,27h dup(0)
  34. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  35. ; CODE
  36. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  37.  
  38. ;═════════════════════════════════════════════════════════════════════════════
  39. irq1:
  40.         push eax ebx ds
  41.         mov ds,cs:_seldata
  42.         in al,60h
  43.         movzx ebx,al
  44.         btr ebx,7
  45.         setnc al
  46.         mov _kbtbl0[ebx],al
  47.         or _kbtbl1[ebx],al
  48.         or al,al
  49.         jz short irq1d
  50.         mov ah,_kbtbl0[2ah]
  51.         or ah,_kbtbl0[36h]
  52.         mov bh,ah
  53.         shl bh,7
  54.         add bl,bh
  55.         movzx ebx,bl
  56.         mov al,kbxtbl[ebx]
  57.         or al,al
  58.         jz short irq1d
  59.         mov _kbchar,al
  60.         mov _kbhit,1
  61.         mov al,_kbtbl0[1dh]
  62.         shl al,1
  63.         or al,_kbtbl0[38h]
  64.         shl al,1
  65.         or al,ah
  66.         mov _kbshift,al
  67. irq1d:
  68.         pop ds ebx
  69.         mov al,20h
  70.         out 20h,al
  71.         pop eax
  72.         sti
  73.         iretd
  74.  
  75. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  76. ; Initialize keyboard handler
  77. ; Out:
  78. ;   EAX,BX,EDX,EDI - ?
  79. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  80. _initkb:
  81.         mov bl,1
  82.         call _getirqvect
  83.         mov opmirq1,edx
  84.         mov edx,offset irq1
  85.         call _setirqvect
  86.         mov edi,offset kbrmirqbuf
  87.         call _rmpmirqset
  88.         mov ormirq1,eax
  89.         ret
  90.  
  91. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  92. ; Reset keyboard handler
  93. ; Out:
  94. ;   EAX,BX,EDX - ?
  95. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  96. _resetkb:
  97.         mov bl,1
  98.         mov eax,ormirq1
  99.         call _rmpmirqfree
  100.         mov edx,opmirq1
  101.         jmp _setirqvect
  102.  
  103. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  104. ; Get the last character pressed
  105. ; Out:
  106. ;   AL - case adjusted character
  107. ;   AH - shift state bits: 0=SHIFT, 1=ALT, 2=CTRL
  108. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  109. _getch:
  110.         cmp _kbhit,0
  111.         je _getch
  112.         mov _kbhit,0
  113.         mov ax,word ptr _kbchar
  114.         ret
  115.  
  116. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  117. ; Clear all kb stuff
  118. ; Out:
  119. ;   EAX,ECX,EDI - ?
  120. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  121. _clearkb:
  122.         mov edi,offset _kbtbl0
  123.         xor eax,eax
  124.         mov ecx,40h
  125.         rep stosd
  126.         mov _kbshift,0
  127.         mov _kbhit,0
  128.         ret
  129.  
  130. code32  ends
  131.         end
  132.  
  133.